package com.yange.accountbook.net.api;


import com.yange.accountbook.entity.AccountEntity;
import com.yange.accountbook.entity.BooksEntity;
import com.yange.accountbook.entity.DeleteRecordPostEntity;
import com.yange.accountbook.net.Api;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.QueryMap;

/**
 * 基于retrofit的注解接口
 */

public interface ApiService {


    /* 文件上传单张 */
    @Multipart
    @POST("{path}")
    Observable<ResponseBody> uploadFile(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Part MultipartBody.Part file);


    /* 图片上传多张 */
    @Multipart
    @POST("{path}")
    Observable<ResponseBody> uploadFiles(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Part List<MultipartBody.Part> file);

    /**
     * @param requestBody
     * @return
     */
    @POST("{url}")
    Observable<ResponseBody> postBody(@Body RequestBody requestBody);


    /**
     * post 请求 body
     *
     * @param path
     * @param headers
     * @param requestBody
     * @return
     */
    @POST("{path}")
    Observable<ResponseBody> invokePost(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Body RequestBody requestBody);






    /**
     *删除明细
     *
     * @param path
     * @param headers
     * @param requestBody
     * @return
     */
    @Headers("Content-Type:application/json")
    @POST("{path}")
    Observable<ResponseBody> deleteRecordOrder(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Body DeleteRecordPostEntity requestBody);


    /**
     *
     * @param path
     * @param headers
     * @param requestBody
     * @return
     */
    @Headers("Content-Type:application/json")
    @POST("{path}")
    Observable<ResponseBody> bookSort(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Body ArrayList<BooksEntity> requestBody);

    /**
     *
     * @param path
     * @param headers
     * @param requestBody
     * @return
     */
    @Headers("Content-Type:application/json")
    @POST("{path}")
    Observable<ResponseBody> accountSort(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Body ArrayList<AccountEntity> requestBody);

    @Headers("Content-Type:application/json")
    @POST("{path}")
    Observable<ResponseBody> sort(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @Body List<Integer> requestBody);


    /**
     * post请求 表单
     *
     * @param path
     * @param headers
     * @param param
     * @return
     */
    @FormUrlEncoded
    @POST("{path}")
    Observable<ResponseBody> invokePost2(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @FieldMap Map<String, Object> param);

    /**
     * get 请求 带header
     *
     * @param path
     * @param headers
     * @param param
     * @return
     */
    @GET("{path}")
    Observable<ResponseBody> invokeGet(@Path(value = "path", encoded = true) String path, @HeaderMap Map<String, String> headers, @QueryMap Map<String, Object> param);

    /**
     * get 请求 不带header
     *
     * @param path
     * @param param
     * @return
     */
    @GET("{path}")
    Observable<ResponseBody> invokeGet(@Path(value = "path", encoded = true) String path, @QueryMap Map<String, String> param);


    @GET(Api.BOOK_INFO)
    Observable<ResponseBody> invokeGetBookInfo(@HeaderMap Map<String, String> headers, @Path(value = "id", encoded = true) int id);


    @GET(Api.GET_ICON_IN_ITEM)
    Observable<ResponseBody> invokeGetIconList(@HeaderMap Map<String, String> headers, @Path(value = "moneyType", encoded = true) String moneyType);


    @GET(Api.ACCOUNT_INFO)
    Observable<ResponseBody> invokeGetAccountInfo(@HeaderMap Map<String, String> headers, @Path(value = "id", encoded = true) int id);

    /**
     * 通过账本码添加
     * @param headers
     * @param code
     * @return
     */
    @POST(Api.BOOK_SAVE_BY_CODE)
    Observable<ResponseBody> addBookByCode(@HeaderMap Map<String, String> headers, @Path(value = "code", encoded = true) String code);


    @POST(Api.SET_DAY)
    Observable<ResponseBody> setDay(@HeaderMap Map<String, String> headers, @Path(value = "day", encoded = true) int day);

    @POST(Api.PERIOD_STATUS)
    Observable<ResponseBody> setPeriodStatus(@HeaderMap Map<String, String> headers, @Path(value = "enable", encoded = true) boolean enable);


}
